<?php

if (!defined('BASEPATH'))
    exit('No direct script access allowed');

class Login extends CI_Controller {

    function __construct() {
        parent::__construct();
        $this->load->helper('form', 'url');
        $this->load->library('session');
        $this->load->model('all');
    }

    function index() {
        $this->load->view('login/login_view');
    }

    function validasi_login() {
        $login = array(
            'username' => $this->input->post('username'),
            'password' => $this->encrypt->sha1($this->input->post('password'))
        );
        $query = $this->all->login($login);
        if ($query) {
            $user = array(
                'username' => $this->input->post('username'), //session yang disimpan adalah username
                'akses' => 'admin', //session yang disimpan adalah username
                'log_in' => true); //session yang disimpan adalah log_in bernilai kembalian TRUE
            $this->session->set_userdata($user); //untuk menyimpan session
            redirect('home');
        } else {
           redirect(); //artinya dia di redirect ke base_url dia. Liat settingan di config->base_url
        }
    }

}

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
?>
